<script type="text/javascript">
    $(function () {
        const url = 'https://other-player-ra01-sycdn.kuwo.cn/87171eed42a7e77c4147b0c503f12078/650fc96e/resource/n3/320/74/27/4113470514.mp3?bitrate$320&amp;format$mp3&amp;type$convert_url2'.replace(new RegExp('&amp;', 'g'), "&");
        const ap = new APlayer({
            container: document.getElementById('aplayer'),
            autoplay: false,
            theme: '#0e90d2',
            lrcType: 1,
            preload: 'none',
            // loop: 'none',
            order: 'list',
        });
        ap.on('listswitch', function () {
            layer.tips('点击这里播放', '.aplayer-button', {
                tips: [3, '#FF5722'],
            });
        });


        $('#btn-download-mp3').attr('href', 'http://other-player-ra01-sycdn.kuwo.cn/87171eed42a7e77c4147b0c503f12078/650fc96e/resource/n3/320/74/27/4113470514.mp3?bitrate$320&amp;format$mp3&amp;type$convert_url2');

        var name = '稻香' + '-' + '周杰伦';
        $('#btn-download-mp3').attr('download', name + '.mp3');
        $('#btn-download-lrc').attr('download', name + '.lrc');
        var is_error = false;
        ap.on('error', function () {
            is_error = true;
            console.log(ap.audio.currentSrc)
            $.post('/api/err_music', {id: 112019});
        });



        $('#btn-download-mp3').click(function () {


            //
            if (is_error) {
                layer.msg('当前歌曲解析出错，暂不能下载', {offset: '100px', icon: 0});
                return false;
            }
            $.ajaxSettings.async = false;
            let adshow = false;
            $.get("/api/ad_handle", function (data, status) {
                if (data.code != 0) {
                    return true;
                } else {
                    $('#ad-modal-body').html(data.msg);
                    $('#ad-modal').modal('toggle');
                    adshow = true;
                    return false;
                }
            });
            $.ajaxSettings.async = true;
            if (adshow) return false;

            if (is_qq_wx_tb()) {
                return false;
            }

            $.post("/api/download_log",
                {
                    music_id: '112019'
                });

        });

        ap.list.add([{
            name: '稻香',
            artist: '周杰伦',
            url: url,
            cover: 'https://img4.kuwo.cn/star/albumcover/120/72/44/3648126291.jpg',
            lrc: '"[00:3.48]\u7a3b\u9999 - \u5468\u6770\u4f26 \u0026\u6797\u4fca\u6770\n[00:8.64]\u8bcd\uff1a\u5468\u6770\u4f26\n[00:15.6]\u66f2\uff1a\u5468\u6770\u4f26\n[00:20.27]\u5bf9\u8fd9\u4e2a\u4e16\u754c\u5982\u679c\u4f60\u6709\u592a\u591a\u7684\u62b1\u6028\n[00:23.52]\u8dcc\u5012\u4e86\u5c31\u4e0d\u6562\u7ee7\u7eed\u5f80\u524d\u8d70\n[00:26.56]\u4e3a\u4ec0\u4e48\u4eba\u8981\u8fd9\u4e48\u7684\u8106\u5f31\u5815\u843d\n[00:30.79]\u8bf7\u4f60\u6253\u5f00\u7535\u89c6\u770b\u770b\n[00:32.37]\u591a\u5c11\u4eba\u4e3a\u751f\u547d\u5728\u52aa\u529b\u52c7\u6562\u7684\u8d70\u4e0b\u53bb\n[00:36.38]\u6211\u4eec\u662f\u4e0d\u662f\u8be5\u77e5\u8db3\n[00:38.84]\u73cd\u60dc\u4e00\u5207\u5c31\u7b97\u6ca1\u6709\u62e5\u6709\n[00:43.47]\u8fd8\u8bb0\u5f97\u4f60\u8bf4\u5bb6\u662f\u552f\u4e00\u7684\u57ce\u5821\n[00:46.96]\u968f\u7740\u7a3b\u9999\u6cb3\u6d41\u7ee7\u7eed\u5954\u8dd1\n[00:49.88]\u5fae\u5fae\u7b11 \u5c0f\u65f6\u5019\u7684\u68a6\u6211\u77e5\u9053\n[00:55.31]\u4e0d\u8981\u54ed\u8ba9\u8424\u706b\u866b\u5e26\u7740\u4f60\u9003\u8dd1\n[00:58.72]\u4e61\u95f4\u7684\u6b4c\u8c23\u6c38\u8fdc\u7684\u4f9d\u9760\n[01:02.6]\u56de\u5bb6\u5427 \u56de\u5230\u6700\u521d\u7684\u7f8e\u597d\n[01:50.93]\u4e0d\u8981\u8fd9\u4e48\u5bb9\u6613\u5c31\u60f3\u653e\u5f03\n[01:54.4]\u5c31\u50cf\u6211\u8bf4\u7684\n[01:56.9]\u8ffd\u4e0d\u5230\u7684\u68a6\u60f3\u6362\u4e2a\u68a6\u4e0d\u5c31\u5f97\u4e86\n[01:61.95]\u4e3a\u81ea\u5df1\u7684\u4eba\u751f\u9c9c\u8273\u4e0a\u8272\n[01:65.87]\u5148\u628a\u7231\u6d82\u4e0a\u559c\u6b22\u7684\u989c\u8272\n[01:70.28]\u7b11\u4e00\u4e2a\u5427\n[01:72.03]\u529f\u6210\u540d\u5c31\u4e0d\u662f\u76ee\u7684\n[01:75.27]\u8ba9\u81ea\u5df1\u5feb\u4e50\u5feb\u4e50\u8fd9\u624d\u53eb\u505a\u610f\u4e49\n[01:80.22]\u7ae5\u5e74\u7684\u7eb8\u98de\u673a\n[01:82.5]\u73b0\u5728\u7ec8\u4e8e\u98de\u56de\u6211\u624b\u91cc\n[01:89.75]\u6240\u8c13\u7684\u90a3\u5feb\u4e50\n[01:91.83]\u8d64\u811a\u5728\u7530\u91cc\u8ffd\u873b\u8713\u8ffd\u5230\u7d2f\u4e86\n[01:96.5]\u5077\u6458\u6c34\u679c\u88ab\u871c\u8702\u7ed9\u53ee\u5230\u6015\u4e86\n[02:01.8]\u8c01\u5728\u5077\u7b11\u5462\n[02:04.58]\u6211\u9760\u7740\u7a3b\u8349\u4eba\n[02:06.4]\u5439\u7740\u98ce \u5531\u7740\u6b4c \u7761\u7740\u4e86\n[02:12.13]\u5348\u540e\u5409\u4ed6\u5728\u866b\u9e23\u4e2d\u66f4\u6e05\u8106\n[02:16.52]\u9633\u5149\u6d12\u5728\u8def\u4e0a\u5c31\u4e0d\u6015\u5fc3\u788e\n[02:20.82]\u73cd\u60dc\u4e00\u5207 \u5c31\u7b97\u6ca1\u6709\u62e5\u6709\n[02:28.55]\u8fd8\u8bb0\u5f97\u4f60\u8bf4\u5bb6\u662f\u552f\u4e00\u7684\u57ce\u5821\n[02:34.23]\u968f\u7740\u7a3b\u9999\u6cb3\u6d41\u7ee7\u7eed\u5954\u8dd1\n[02:39.02]\u5fae\u5fae\u7b11 \u5c0f\u65f6\u5019\u7684\u68a6\u6211\u77e5\u9053\n[02:48.32]\u4e0d\u8981\u54ed\u8ba9\u8424\u706b\u866b\u5e26\u7740\u4f60\u9003\u8dd1\n[02:53.8]\u4e61\u95f4\u7684\u6b4c\u8c23\u6c38\u8fdc\u7684\u4f9d\u9760\n[02:58.8]\u56de\u5bb6\u5427 \u56de\u5230\u6700\u521d\u7684\u7f8e\u597d\n[02:67.98]\u8fd8\u8bb0\u5f97\u4f60\u8bf4\u5bb6\u662f\u552f\u4e00\u7684\u57ce\u5821\n[02:73.38]\u968f\u7740\u7a3b\u9999\u6cb3\u6d41\u7ee7\u7eed\u5954\u8dd1\n[02:78.1]\u5fae\u5fae\u7b11 \u5c0f\u65f6\u5019\u7684\u68a6\u6211\u77e5\u9053\n[02:87.1]\u4e0d\u8981\u54ed\u8ba9\u8424\u706b\u866b\u5e26\u7740\u4f60\u9003\u8dd1\n[02:92.78]\u4e61\u95f4\u7684\u6b4c\u8c23\u6c38\u8fdc\u7684\u4f9d\u9760\n[02:97.55]\u56de\u5bb6\u5427 \u56de\u5230\u6700\u521d\u7684\u7f8e\u597d\n"',
        }]);

        $('.expand').click(function () {
            if ($(this).attr('data-status') === 'up') {
                $('.content-lrc').addClass('height-auto');
                $(this).attr('data-status', 'down')
                $(this).text('收起')
            } else {
                $('.content-lrc').removeClass('height-auto');
                $(this).attr('data-status', 'up')
                $(this).text('展开')
            }
        });


        setTimeout('autoScroll("#download-log")', 3500);
    });

    function is_qq_wx_tb() {
        var ua = navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger\/[0-9]/i)) {
            layer.msg("微信进入的用户请换用系统自带浏览器重新打开本站才能进行歌曲下载", {offset: '100px', icon: 7});
            return true;
        }

        if (ua.match(/QQ\/[0-9]/i)) {
            layer.msg("QQ进入的用户请换用系统自带浏览器重新打开本站才能进行歌曲下载", {offset: '100px', icon: 7});
            return true;
        }

        if (ua.match(/tieba\/[0-9]/i)) {
            layer.msg("百度贴吧进入的用户请换用系统自带浏览器重新打开本站才能进行歌曲下载", {
                offset: '100px',
                icon: 7
            });
            return true;
        }
        return false;
    }

    function autoScroll(obj) {
        $(obj).find("ul").animate({
                marginTop: "-1rem"
            },
            1000,
            function () {
                $(this).css({
                    marginTop: "0"
                }).find("li:first").appendTo(this);
                setTimeout('autoScroll("#download-log")', 3500);
            });
    }
</script>
